package com.stox.charting.ui.swing.widget;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.stox.charting.ui.swing.model.BarSpan;
import com.stox.charting.ui.swing.model.price.PriceChartModel;
import com.stox.charting.ui.swing.view.ChartingInternalFrameView;
import com.stox.core.ui.swing.wrapper.JComboBox;

public class BarSpanComboBox extends JComboBox<BarSpan> implements ActionListener{
	private static final long serialVersionUID = 6647286354635025088L;

	public BarSpanComboBox() {
		super(BarSpan.values());
		setSelectedItem(BarSpan.DAILY);
		addActionListener(this);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		ChartingInternalFrameView view = ChartingInternalFrameView.getLastSelectedView();
		if(view != null){
			PriceChartModel<?> model = view.getPriceChartView().getPriceChart().getModel();
			model.fireChartModelChangedEvent("backupData");
			view.repaintChartViews();
		}
	}
	
}
